<html>
    <head>
        <style>
            body {
                padding: 0;
                margin: 0;
            }

            #container {
                display: flex;
                position: relative;
                top: 100px;
                left: 100px;
                width: 300px;
                height: 200px;
            }

            #a {
                background: #00cc88;
            }

            #b {
                background: blue;
            }

            #container > div {
                height: 200px;
                flex: 1;
            }

            #trigger-overflow {
                width: 1px;
                height: 1px;
                position: absolute;
                top: 2000px;
                left: 2000px;
            }

            [data-layout-correct="false"] {
                background: #dd1144 !important;
                opacity: 0.5;
            }
        </style>
    </head>
    <body>
        <div id="container">
            <div id="a" data-layout-correct="true"></div>
            <div id="b" data-layout-correct="true"></div>
        </div>
        <div id="trigger-overflow"></div>

        <script type="module" src="/src/imports/projection.js"></script>
        <script type="module" src="/src/imports/script-assert.js"></script>
        <script type="module" src="/src/imports/script-undo.js"></script>
        <script type="module">
            const { createNode } = window.Undo
            const { matchOpacity, matchBorderRadius, matchViewportBox } =
                window.Assert
            const { frame } = window.Projection

            const container = document.getElementById("container")
            const a = document.getElementById("a")
            const b = document.getElementById("b")
            const aOrigin = a.getBoundingClientRect()
            const bOrigin = b.getBoundingClientRect()

            const aProjection = createNode(a)
            const bProjection = createNode(b)
            aProjection.setValue("borderRadius", 20)

            aProjection.willUpdate()
            bProjection.willUpdate()

            container.style.flexDirection = "column-reverse"

            aProjection.root.didUpdate()

            frame.postRender(() => {
                matchViewportBox(a, aOrigin)
                matchViewportBox(b, bOrigin)
                matchOpacity(a, 1)
                matchOpacity(b, 1)
                matchBorderRadius(a, "13.3333% / 10%")
                matchBorderRadius(b, "")
            })
        </script>
    </body>
</html>
